<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/7
 * Time: 16:12
 */
use PHPRouter\RouteCollection;
use PHPRouter\Router;
use PHPRouter\Route;

$collection = new RouteCollection();

$collection->attachRoute(new Route('/home/:id', array(
	'_controller' => 'App\Demo\Controllers\HomeController::home',
	'methods' => 'GET',
	'name' => 'home'
)));

$collection->attachRoute(new Route('/', array(
	'_controller' => 'App\Demo\Controllers\IndexController::doo',
	'methods' => 'GET',
	'name' => 'dooname',
	'parameters'=> ['template_file'=>'ajax'],
)));

$router = new Router($collection);
$router->setBasePath('/');
$route = $router->matchCurrentRequest();

var_dump($route);

echo '<br/>';

//print_r ($route->getParameters());

print_r ($router->generate('home',array('id' => '5')));